import * as types from './mutation-types'

/**
 * id 获取某一期数据
*/
export const selectOne = function ({commit, state}, id) {
  let ones = state.ones.slice()
  let currentIndex = findIndex(ones, id) // 当前id对应的索引

  commit(types.SET_CURRENT_ONE, ones[currentIndex])
}

function findIndex (list, id) {
  return list.findIndex(item => {
    return item.id === id
  })
}
